from M2Crypto import RSA

def getPublicKey(keys):
    pubKey = RSA.new_pub_key(keys.pub())
    return pubKey.as_pem(cipher=None)

def encrypt(plaintext,keys):
    encText = keys.private_encrypt(plaintext, 1)
    return encText

def decrypt(encText,pubKey):
    dec = pubKey.public_decrypt(encText, 1)
    return decl

def loadKeys(pem):
    return RSA.load_key_string(pem)
